#!/usr/bin/env bash

if [[ ! -d "./target" ]]; then
    mkdir ./target
    echo "mkdir target success!"
fi

rm -rf ./target/*
echo "clear dir target sucess"
cp -r ./src ./target/test
yes | cp -i ./src/config/config-test.js ./target/test/config/config.js
yes | cp -i ./src/const-prod.js ./target/test/const.js
yes | cp -i ./src/config/redis-test.json ./target/test/config/redis.json
yes | cp -i ./src/config/session-test.json ./target/test/config/session.json
rm ./target/test/config/config-prod.js
rm ./target/test/config/config-test.js
rm ./target/test/config/config-gprod.js
rm ./target/test/config/redis-prod.json
rm ./target/test/config/redis-test.json
rm ./target/test/config/session-prod.json
rm ./target/test/config/session-test.json
rm -rf ./target/game/config

echo ""
echo "cp src to target game success!"

cd ./target
echo "cd dir target:"
pwd
tar -cvf ./test.tar.gz ./test
rm -rf ./test
echo "package game success!"